package svc

import (
	"github.com/zeromicro/go-zero/rest"
	"github.com/zeromicro/go-zero/zrpc"
	"store/api/internal/config"
	"store/api/internal/middleware"
	"store/storerpc/storerpcclient"
)

type ServiceContext struct {
	Config              config.Config
	StoreRpc            storerpcclient.Storerpc
	UserAgentMiddleware rest.Middleware
}

func NewServiceContext(c config.Config) *ServiceContext {
	return &ServiceContext{
		Config:              c,
		StoreRpc:            storerpcclient.NewStorerpc(zrpc.MustNewClient(c.StoreRpc)),
		UserAgentMiddleware: middleware.NewUserAgentMiddleware().Handle,
	}
}
